﻿Imports System.Windows.Markup
Imports System.Windows

Public Class FeatureFlag
    Inherits MarkupExtension

    Public Property IsEnabled As Boolean

    Public Property Feature As Type

    Public Sub New()
        IsEnabled = True
    End Sub

    Public Overrides Function ProvideValue(serviceProvider As IServiceProvider) As Object
        Dim target = DirectCast(serviceProvider.GetService(GetType(IProvideValueTarget)), IProvideValueTarget)
        Dim host = DirectCast(target.TargetObject, UIElement)

        Dim v As Visibility = If(Features.IsEnabled(Feature) = IsEnabled, Visibility.Visible, Visibility.Collapsed)
        Return v
    End Function

End Class
